package com.powernode.teatraceability.dao.login;

import com.powernode.teatraceability.pojo.login.Account;
import com.powernode.teatraceability.pojo.login.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    /**
     * 通过人员编号查询人员信息
     */
    User selectByUserId(@Param("rybh") String rybh);

    /**
     * 更新企业账号信息
     */
    @Update("update t_ry set evidence = #{evidence} where rybh = #{rybh}")
    int UpdateInfo(@Param("evidence") String evi, @Param("rybh") String rybh);

    @Update("update t_ry set active = #{active} where rybh = #{rybh}")
    int updateActive(@Param("active") Integer act, @Param("rybh") String rybh);

    /**
     * 根据用户名或邮箱查找用户
     * @param text
     * @return
     */
    @Select("select id, rybh 'username', kl 'password', group_name, email from t_ry where rybh = #{text} or email = #{text}")
    Account findAccountByNameOrEmail(String text);
    @Select("select * from t_ry where rybh = #{text} or email = #{text}")
    User findAccountUserByNameOrEmail(String text);

    /**
     *
     * @param user
     * @return
     */
    @Insert("insert into t_ry(rybh, rymc, kl, group_name, dh, qydm, email) values (#{rybh}, #{rymc}, #{kl}, #{groupName}, #{dh}, #{qydm}, #{email})")
    int CreateAccount(User user);

    @Update("update t_ry set kl = #{kl} where email = #{email}")
    int resetPasswordByEmail(@Param("kl") String password, @Param("email") String email);
}
